package com.neuedu.controller.workrule;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.neuedu.factory.ClassFactory;
import com.neuedu.service.WorkRuleService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "QueryWorkRuleServlet", urlPatterns = "/his/queryworkrule")
public class QueryWorkRuleServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        WorkRuleService wrs = (WorkRuleService) ClassFactory.createObj("WorkRuleService");
        List<Map<String, Object>> list = wrs.queryWorkRule();
        ObjectMapper om = new ObjectMapper();
        String s = om.writeValueAsString(list);
        response.getWriter().append(s);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
